package com.tyc.register.config;


import com.tyc.register.model.Black;
import com.tyc.register.model.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
/**
 * @Import导入的组件名为全类名
 * 参数传入指定组件，或者ImportSelector自类,或者ImportBeanDefinitionRegistrar
 */
@Import({Black.class,MyImportSelector.class,MyImportBeanDefinationRegistery.class})
public class TestConfig {

    @Bean
    @Conditional(value = WindowsCondition.class)
    public User user_windows(){
        return new User("windows",21);
    }

    @Bean
    @Conditional(value = LinuxCondition.class)
    public User user_linux(){
        return new User("linux",22);
    }

    /**
     * 注入FactoryBean
     * @return
     */
    @Bean
    public MyFactoryBean myFactoryBean(){
        return new MyFactoryBean();
    }
}
